package com.itheima.edu.info.manager.day14;

import java.util.concurrent.ConcurrentHashMap;

public class ConcurrentHashMapTest {
    public static void main(String[] args) {
        ConcurrentHashMap<Integer, String> concurrentHashMap = new ConcurrentHashMap();
        Thread td = new Thread(() -> {
            for (int i = 0; i < 200; i++) {
                //1.8扩容
                concurrentHashMap.put(i, Thread.currentThread().getName() + "~~" + (i + 1));
            }
        });
        Thread td1 = new Thread(() -> {
            for (int i = 200; i < 400; i++) {
                concurrentHashMap.put(i, Thread.currentThread().getName() + "~~" + (i + 1));
            }
        });
        td.setName("001");
        td1.setName("002");
        td.start();
        td1.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(concurrentHashMap);
    }
}
